package com.patchmanage.back.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.patchmanage.back.dto.InventoryPatchDto;
import com.patchmanage.back.entity.InventoryPatch;
import com.patchmanage.back.mapper.InventoryPatchMapper;
import com.patchmanage.back.service.IInventoryPatchService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author huizhao
 * @since 2021-07-11
 */
@Service
public class InventoryPatchServiceImpl extends ServiceImpl<InventoryPatchMapper, InventoryPatch> implements IInventoryPatchService {

    public IPage<InventoryPatchDto> listEx(IPage<InventoryPatchDto> page, Map<String, Object> map){
        String host = (String) map.get("host");
        QueryWrapper qw = new QueryWrapper();
        qw.select("DISTINCT query_id");
        qw.orderByDesc("query_id");
        List<InventoryPatch> selectList = list(qw);
        if (selectList.size() > 0) {
            map.put("query_id", selectList.get(0).getQueryId());
        }

        return baseMapper.selectInventoryPatchExPage(page,map);
    }
}
